<?php

include("../function.php");
include_once("../class/system_class.php");
include_once("../alisms/sendSms.php");

$_system=new system_class();
$systemparameters=$_system->system_information(1);

session_start();

if(empty($_SESSION['ID'])){
    $arr = array(
        'code'=>'2',
        'msg'=>'非法访问'
    );
    echo json_encode($arr);
    exit;
}

$sql = "SELECT * FROM `member` WHERE id='".$_SESSION['ID']."'";
$query = mysql_query($sql);
if (mysql_num_rows($query)>0){
      while($row=mysql_fetch_array($query)){

          $smscode = rand(10000, 99999);
          $send = new alisendsms();
          $sendsms = $send->sendSms($systemparameters['access_key_id'],$systemparameters['access_key_secret'],$row['userid'],'SMS_138845011','code',$smscode);
          $sendsms = json_decode( json_encode( $sendsms),true);
          if($sendsms['Code']=='OK'){
              $_SESSION['editpwdsms']=$smscode;
              $arr = array(
                  'code'=>'1'
              );
              echo json_encode($arr);
              exit;
          }else{
              $arr = array(
                  'code'=>'2',
                  'msg'=>$sendsms['Message']
              );
              echo json_encode($arr);
              exit;
          }

      }
}else{
    $arr = array(
        'code'=>'2',
        'msg'=>'账号不存在'
    );
    echo json_encode($arr);
    exit;
}

?>
